import { ApiProperty } from '@nestjs/swagger';
import { Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { User } from '../../user/entities/user.entity';

@Entity('sys_file')
export class File {
  @ApiProperty({ type: String, description: 'id' })
  @PrimaryGeneratedColumn('uuid')
  id: string;
  @ApiProperty({ type: String, description: '文件名' })
  @Column({ type: 'varchar', comment: '文件名' })
  name: string;
  @ApiProperty({ type: String, description: '保存的文件名' })
  @Column({ type: 'varchar', comment: '保存的文件名', name: 'save_name' })
  saveName: string;

  @ApiProperty({ type: String, description: '文件类型' })
  @Column({
    type: 'varchar',
    comment: '文件类型',
  })
  type: string;
  @ApiProperty({ type: String, description: '文件地址' })
  @Column({
    type: 'varchar',
    comment: '文件地址',
  })
  url: string;
  @ApiProperty({ type: String, description: '文件大小' })
  @Column({
    type: 'varchar',
    comment: '文件大小',
  })
  size: string;
  @Column({
    type: 'int',
    comment: '删除标记 0-未删除 1-删除',
    name: 'is_delete',
    default: 0,
  })
  isDelete: number;
  @CreateDateColumn({
    type: 'timestamp',
    name: 'create_date',
    comment: '创建时间',
  })
  createDate: Date;

  @UpdateDateColumn({
    type: 'timestamp',
    name: 'update_date',
    comment: '更新时间',
  })
  updateDate: Date;
  @ManyToOne((type) => User, (user) => user.file, { eager: true })
  user: User;
}
